<!doctype html>



  


<html class="theme-next pisces use-motion">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>



<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />












  <link href="/vendors/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css"/>




  <link href="//fonts.googleapis.com/css?family=Lato:300,400,700,400italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">



<link href="/vendors/font-awesome/css/font-awesome.min.css?v=4.4.0" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.0.0" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="ip,php," />





  <link rel="alternate" href="/atom.xml" title="追背影的熊孩子" type="application/atom+xml" />




  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.0.0" />






<meta name="description" content="踩过的坑Using $this when not in object context in 静态方法内无法使用$this,解决方法：
self::method();
参考地址
json_decode 时整形溢出，变为科学记数法solutions:

json_decode($arr, TRUE, 512, JSON_BIGINT_AS_STRING)
preg_replace(&amp;#39;/(&amp;qu">
<meta property="og:type" content="article">
<meta property="og:title" content="PHP知识点">
<meta property="og:url" content="http://b.fengbl.cn/2015/12/06/php-summary/index.html">
<meta property="og:site_name" content="追背影的熊孩子">
<meta property="og:description" content="踩过的坑Using $this when not in object context in 静态方法内无法使用$this,解决方法：
self::method();
参考地址
json_decode 时整形溢出，变为科学记数法solutions:

json_decode($arr, TRUE, 512, JSON_BIGINT_AS_STRING)
preg_replace(&amp;#39;/(&amp;qu">
<meta property="og:updated_time" content="2016-01-15T12:29:14.471Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="PHP知识点">
<meta name="twitter:description" content="踩过的坑Using $this when not in object context in 静态方法内无法使用$this,解决方法：
self::method();
参考地址
json_decode 时整形溢出，变为科学记数法solutions:

json_decode($arr, TRUE, 512, JSON_BIGINT_AS_STRING)
preg_replace(&amp;#39;/(&amp;qu">



<script type="text/javascript" id="hexo.configuration">
  var NexT = window.NexT || {};
  var CONFIG = {
    scheme: 'Pisces',
    sidebar: '[object Object]',
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: 0,
      author: '博主'
    }
  };
</script>

  <title> PHP知识点 | 追背影的熊孩子 </title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  



  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "//hm.baidu.com/hm.js?132dfd4f90476131a6139e7cd32e426b";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>




  
  
    
  

  <div class="container one-collumn sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-meta ">
  

  <div class="custom-logo-site-title">
    <a href="/"  class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <span class="site-title">追背影的熊孩子</span>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>
  <p class="site-subtitle">Notes & Stories</p>
</div>

<div class="site-nav-toggle">
  <button>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
  </button>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu menu-left">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-home fa-fw"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories" rel="section">
            
              <i class="menu-item-icon fa fa-th fa-fw"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives" rel="section">
            
              <i class="menu-item-icon fa fa-archive fa-fw"></i> <br />
            
            归档
          </a>
        </li>
      

      
      
      
        <li class="menu-item menu-item-search">
          <a href="#" class="st-search-show-outputs">
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br />
            
            搜索
          </a>
        </li>
      
    </ul>
  

  
    <div class="site-search">
      
  <form class="site-search-form">
  <input type="text" id="st-search-input" class="st-search-input st-default-search-input" />
</form>

<script type="text/javascript">
  (function(w,d,t,u,n,s,e){w['SwiftypeObject']=n;w[n]=w[n]||function(){
    (w[n].q=w[n].q||[]).push(arguments);};s=d.createElement(t);
    e=d.getElementsByTagName(t)[0];s.async=1;s.src=u;e.parentNode.insertBefore(s,e);
  })(window,document,'script','//s.swiftypecdn.com/install/v2/st.js','_st');

  _st('install', 'T4o6Q_jTr-CKSx9X79oD','2.0.0');
</script>



    </div>
  
</nav>

 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  
  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                PHP知识点
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            <span class="post-meta-item-icon">
              <i class="fa fa-calendar-o"></i>
            </span>
            <span class="post-meta-item-text">发表于</span>
            <time itemprop="dateCreated" datetime="2015-12-06T22:27:03+08:00" content="2015-12-06">
              2015-12-06
            </time>
          </span>

          
            <span class="post-category" >
              &nbsp; | &nbsp;
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
              
                <span itemprop="about" itemscope itemtype="https://schema.org/Thing">
                  <a href="/categories/php/" itemprop="url" rel="index">
                    <span itemprop="name">php</span>
                  </a>
                </span>

                
                

              
            </span>
          

          
            
              <span class="post-comments-count">
                &nbsp; | &nbsp;
                <a href="/2015/12/06/php-summary/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="2015/12/06/php-summary/" itemprop="commentsCount"></span>
                </a>
              </span>
            
          

          

          
          
        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        <h3 id="&#x8E29;&#x8FC7;&#x7684;&#x5751;">&#x8E29;&#x8FC7;&#x7684;&#x5751;</h3><h4 id="using-this-when-not-in-object-context-in"><code>Using $this when not in object context in</code></h4><p> &#x9759;&#x6001;&#x65B9;&#x6CD5;&#x5185;&#x65E0;&#x6CD5;&#x4F7F;&#x7528;$this,&#x89E3;&#x51B3;&#x65B9;&#x6CD5;&#xFF1A;</p>
<pre><code><span class="keyword">self</span>::<span class="function"><span class="keyword">method</span><span class="params">()</span>;</span>
</code></pre><p><a href="http://blog.csdn.net/yageeart/article/details/6662059" target="_blank" rel="external">&#x53C2;&#x8003;&#x5730;&#x5740;</a></p>
<h4 id="json_decode-&#x65F6;&#x6574;&#x5F62;&#x6EA2;&#x51FA;&#x53D8;&#x4E3A;&#x79D1;&#x5B66;&#x8BB0;&#x6570;&#x6CD5;">json_decode &#x65F6;&#x6574;&#x5F62;&#x6EA2;&#x51FA;&#xFF0C;&#x53D8;&#x4E3A;&#x79D1;&#x5B66;&#x8BB0;&#x6570;&#x6CD5;</h4><p>solutions:</p>
<ol>
<li><code>json_decode($arr, TRUE, 512, JSON_BIGINT_AS_STRING)</code></li>
<li><code>preg_replace(&apos;/(&quot;\w+&quot;):(\d+)/&apos;, &apos;\\1:&quot;\\2&quot;&apos;, $resp)</code>  //&#x9002;&#x914D;&#x8001;&#x7248;PHP</li>
</ol>
<h3 id="&#x5C0F;tips">&#x5C0F;TIPS</h3><h4 id="&#x83B7;&#x53D6;&#x7269;&#x7406;&#x8DEF;&#x5F84;">&#x83B7;&#x53D6;&#x7269;&#x7406;&#x8DEF;&#x5F84;</h4><pre><code>realpath()<span class="comment">;</span>
</code></pre><h4 id="&#x83B7;&#x53D6;&#x670D;&#x52A1;&#x7AEF;&#x5BA2;&#x6237;&#x7AEF;ip">&#x83B7;&#x53D6;&#x670D;&#x52A1;&#x7AEF;&#x3001;&#x5BA2;&#x6237;&#x7AEF;IP</h4><a id="more"></a>
<pre><code>//Server_ip
gethostbyname($_SERVER[<span class="string">&quot;SERVER_NAME&quot;</span>]); 

//Client_ip
<span class="keyword">function</span> clientIP(){   
  <span class="variable">$cIP</span> = getenv(<span class="string">&apos;REMOTE_ADDR&apos;</span>);   
  <span class="variable">$cIP1</span> = getenv(<span class="string">&apos;HTTP_X_FORWARDED_FOR&apos;</span>);   
  <span class="variable">$cIP2</span> = getenv(<span class="string">&apos;HTTP_CLIENT_IP&apos;</span>);   
  <span class="variable">$cIP1</span> ? <span class="variable">$cIP</span> = <span class="variable">$cIP1</span> : null;   
  <span class="variable">$cIP2</span> ? <span class="variable">$cIP</span> = <span class="variable">$cIP2</span> : null;   
  return <span class="variable">$cIP</span>;
 }   
</code></pre><blockquote>
<p>&#x5BA2;&#x6237;&#x7AEF;IP&#x76F8;&#x5173;&#x7684;&#x53D8;&#x91CF;</p>
<ol>
<li><p>$_SERVER[&#x2018;REMOTE_ADDR&#x2019;]; &#x5BA2;&#x6237;&#x7AEF;IP&#xFF0C;&#x6709;&#x53EF;&#x80FD;&#x662F;&#x7528;&#x6237;&#x7684;IP&#xFF0C;&#x4E5F;&#x6709;&#x53EF;&#x80FD;&#x662F;&#x4EE3;&#x7406;&#x7684;IP&#x3002;</p>
</li>
<li><p>$_SERVER[&#x2018;HTTP_CLIENT_IP&#x2019;]; &#x4EE3;&#x7406;&#x7AEF;&#x7684;IP&#xFF0C;&#x53EF;&#x80FD;&#x5B58;&#x5728;&#xFF0C;&#x53EF;&#x4F2A;&#x9020;&#x3002;</p>
</li>
<li><p>$_SERVER[&#x2018;HTTP_X_FORWARDED_FOR&#x2019;]; &#x7528;&#x6237;&#x662F;&#x5728;&#x54EA;&#x4E2A;IP&#x4F7F;&#x7528;&#x7684;&#x4EE3;&#x7406;&#xFF0C;&#x53EF;&#x80FD;&#x5B58;&#x5728;&#xFF0C;&#x53EF;&#x4EE5;&#x4F2A;&#x9020;&#x3002;</p>
</li>
</ol>
<p>&#x670D;&#x52A1;&#x5668;&#x7AEF;IP&#x76F8;&#x5173;&#x7684;&#x53D8;&#x91CF;</p>
<ol>
<li><p>$_SERVER[&#x201C;SERVER_NAME&#x201D;]&#xFF0C;&#x9700;&#x8981;&#x4F7F;&#x7528;&#x51FD;&#x6570;gethostbyname()&#x83B7;&#x5F97;&#x3002;&#x8FD9;&#x4E2A;&#x53D8;&#x91CF;&#x65E0;&#x8BBA;&#x5728;&#x670D;&#x52A1;&#x5668;&#x7AEF;&#x8FD8;&#x662F;&#x5BA2;&#x6237;&#x7AEF;&#x5747;&#x80FD;&#x6B63;&#x786E;&#x663E;&#x793A;&#x3002;</p>
</li>
<li><p>$_SERVER[&#x201C;SERVER_ADDR&#x201D;]&#xFF0C;&#x5728;&#x670D;&#x52A1;&#x5668;&#x7AEF;&#x6D4B;&#x8BD5;&#xFF1A;127.0.0.1&#xFF08;&#x8FD9;&#x4E2A;&#x4E0E;httpd.conf&#x4E2D;BindAddress&#x7684;&#x8BBE;&#x7F6E;&#x503C;&#x76F8;&#x5173;&#xFF09;&#x3002;&#x5728;&#x5BA2;&#x6237;&#x7AEF;&#x6D4B;&#x8BD5;&#x7ED3;&#x679C;&#x6B63;&#x786E;&#x3002;</p>
</li>
</ol>
</blockquote>

      
    </div>

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/ip/" rel="tag">#ip</a>
          
            <a href="/tags/php/" rel="tag">#php</a>
          
        </div>
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2015/12/03/hexo-webhook-autodeploy/" rel="next" title="Webhooks配合shell脚本自动部署Hexo博客到Github">
                <i class="fa fa-chevron-left"></i> Webhooks配合shell脚本自动部署Hexo博客到Github
              </a>
            
          </div>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2015/12/06/Python_crawl/" rel="prev" title="python 爬取知乎">
                python 爬取知乎 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>




    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
      <div class="ds-thread" data-thread-key="2015/12/06/php-summary/"
           data-title="PHP知识点" data-url="http://b.fengbl.cn/2015/12/06/php-summary/">
      </div>
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel ">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="http://ww4.sinaimg.cn/large/c048f998jw1ey8qmhh0pjj20g40ebjs7.jpg"
               alt="Fengit" />
          <p class="site-author-name" itemprop="name">Fengit</p>
          <p class="site-description motion-element" itemprop="description">在成为最厉害最厉害最厉害的道路上.</p>
        </div>
        <nav class="site-state motion-element">
          <div class="site-state-item site-state-posts">
            <a href="/archives">
              <span class="site-state-item-count">19</span>
              <span class="site-state-item-name">日志</span>
            </a>
          </div>

          <div class="site-state-item site-state-categories">
            <a href="/categories">
              <span class="site-state-item-count">9</span>
              <span class="site-state-item-name">分类</span>
              </a>
          </div>

          <div class="site-state-item site-state-tags">
          <a href="/tags">
              <span class="site-state-item-count">27</span>
              <span class="site-state-item-name">标签</span>

          </a>
          </div>

        </nav>

        
          <div class="feed-link motion-element">
            <a href="/atom.xml" rel="alternate">
              <i class="fa fa-rss"></i>
              RSS
            </a>
          </div>
        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/hmilyfyj" target="_blank">
                  
                    <i class="fa fa-github"></i> GitHub
                  
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="http://www.weibo.com/3226007960" target="_blank">
                  
                    <i class="fa fa-weibo"></i> Weibo
                  
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="http://www.zhihu.com/people/feng-ying-jie" target="_blank">
                  
                    <i class="fa fa-globe"></i> zhihu
                  
                </a>
              </span>
            
          
        </div>

        
        

        <div class="links-of-author motion-element">
          
        </div>

      </section>

      
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc-indicator-top post-toc-indicator">
            <i class="fa fa-angle-double-up"></i>
          </div>
          <div class="post-toc">
            
              
            
            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-3"><a class="nav-link" href="#踩过的坑"><span class="nav-number">1.</span> <span class="nav-text">踩过的坑</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#using-this-when-not-in-object-context-in"><span class="nav-number">1.1.</span> <span class="nav-text">Using $this when not in object context in</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#json_decode-时整形溢出变为科学记数法"><span class="nav-number">1.2.</span> <span class="nav-text">json_decode 时整形溢出，变为科学记数法</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#小tips"><span class="nav-number">2.</span> <span class="nav-text">小TIPS</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#获取物理路径"><span class="nav-number">2.1.</span> <span class="nav-text">获取物理路径</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#获取服务端客户端ip"><span class="nav-number">2.2.</span> <span class="nav-text">获取服务端、客户端IP</span></a></li></ol></li></ol></div>
            
          </div>
          <div class="post-toc-indicator-bottom post-toc-indicator">
            <i class="fa fa-angle-double-down"></i>
          </div>
        </section>
      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy;  2015 - 
  <span itemprop="copyrightYear">2016</span>
  <span class="with-love">
    <i class="icon-next-heart fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Fengit</span>
</div>

<div class="powered-by">
  由 <a class="theme-link" href="http://hexo.io">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Pisces
  </a>
</div>



      </div>
    </footer>

    <div class="back-to-top"></div>
  </div>

  


  



  <script type="text/javascript" src="/vendors/jquery/index.js?v=2.1.3"></script>

  <script type="text/javascript" src="/vendors/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  <script type="text/javascript" src="/vendors/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  <script type="text/javascript" src="/vendors/velocity/velocity.min.js"></script>

  <script type="text/javascript" src="/vendors/velocity/velocity.ui.min.js"></script>

  <script type="text/javascript" src="/vendors/fancybox/source/jquery.fancybox.pack.js"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.0.0"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.0.0"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.0.0"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.0.0"></script>



  
  
<script type="text/javascript" src="/js/src/scrollspy.js?v=5.0.0"></script>

<script type="text/javascript" id="sidebar.toc.highlight">
  $(document).ready(function () {
    var tocSelector = '.post-toc';
    var $tocSelector = $(tocSelector);
    var activeCurrentSelector = '.active-current';

    $tocSelector
      .on('activate.bs.scrollspy', function () {
        var $currentActiveElement = $(tocSelector + ' .active').last();

        removeCurrentActiveClass();
        $currentActiveElement.addClass('active-current');

        $tocSelector[0].scrollTop = $currentActiveElement.position().top;
      })
      .on('clear.bs.scrollspy', function () {
        removeCurrentActiveClass();
      });

    function removeCurrentActiveClass () {
      $(tocSelector + ' ' + activeCurrentSelector)
        .removeClass(activeCurrentSelector.substring(1));
    }

    function processTOC () {
      getTOCMaxHeight();
      toggleTOCOverflowIndicators();
    }

    function getTOCMaxHeight () {
      var height = $('.sidebar').height() -
                   $tocSelector.position().top -
                   $('.post-toc-indicator-bottom').height();

      $tocSelector.css('height', height);

      return height;
    }

    function toggleTOCOverflowIndicators () {
      tocOverflowIndicator(
        '.post-toc-indicator-top',
        $tocSelector.scrollTop() > 0 ? 'show' : 'hide'
      );

      tocOverflowIndicator(
        '.post-toc-indicator-bottom',
        $tocSelector.scrollTop() >= $tocSelector.find('ol').height() - $tocSelector.height() ? 'hide' : 'show'
      )
    }

    $(document).on('sidebar.motion.complete', function () {
      processTOC();
    });

    $('body').scrollspy({ target: tocSelector });
    $(window).on('resize', function () {
      if ( $('.sidebar').hasClass('sidebar-active') ) {
        processTOC();
      }
    });

    onScroll($tocSelector);

    function onScroll (element) {
      element.on('mousewheel DOMMouseScroll', function (event) {
          var oe = event.originalEvent;
          var delta = oe.wheelDelta || -oe.detail;

          this.scrollTop += ( delta < 0 ? 1 : -1 ) * 30;
          event.preventDefault();

          toggleTOCOverflowIndicators();
      });
    }

    function tocOverflowIndicator (indicator, action) {
      var $indicator = $(indicator);
      var opacity = action === 'show' ? 1 : 0;
      $indicator.velocity ?
        $indicator.velocity('stop').velocity({
          opacity: opacity
        }, { duration: 100 }) :
        $indicator.stop().animate({
          opacity: opacity
        }, 100);
    }

  });
</script>

<script type="text/javascript" id="sidebar.nav">
  $(document).ready(function () {
    var html = $('html');
    var TAB_ANIMATE_DURATION = 200;
    var hasVelocity = $.isFunction(html.velocity);

    $('.sidebar-nav li').on('click', function () {
      var item = $(this);
      var activeTabClassName = 'sidebar-nav-active';
      var activePanelClassName = 'sidebar-panel-active';
      if (item.hasClass(activeTabClassName)) {
        return;
      }

      var currentTarget = $('.' + activePanelClassName);
      var target = $('.' + item.data('target'));

      hasVelocity ?
        currentTarget.velocity('transition.slideUpOut', TAB_ANIMATE_DURATION, function () {
          target
            .velocity('stop')
            .velocity('transition.slideDownIn', TAB_ANIMATE_DURATION)
            .addClass(activePanelClassName);
        }) :
        currentTarget.animate({ opacity: 0 }, TAB_ANIMATE_DURATION, function () {
          currentTarget.hide();
          target
            .stop()
            .css({'opacity': 0, 'display': 'block'})
            .animate({ opacity: 1 }, TAB_ANIMATE_DURATION, function () {
              currentTarget.removeClass(activePanelClassName);
              target.addClass(activePanelClassName);
            });
        });

      item.siblings().removeClass(activeTabClassName);
      item.addClass(activeTabClassName);
    });

    $('.post-toc a').on('click', function (e) {
      e.preventDefault();
      var targetSelector = NexT.utils.escapeSelector(this.getAttribute('href'));
      var offset = $(targetSelector).offset().top;
      hasVelocity ?
        html.velocity('stop').velocity('scroll', {
          offset: offset  + 'px',
          mobileHA: false
        }) :
        $('html, body').stop().animate({
          scrollTop: offset
        }, 500);
    });

    // Expand sidebar on post detail page by default, when post has a toc.
    NexT.motion.middleWares.sidebar = function () {
      var $tocContent = $('.post-toc-content');

      if (CONFIG.sidebar === 'post') {
        if ($tocContent.length > 0 && $tocContent.html().trim().length > 0) {
          NexT.utils.displaySidebar();
        }
      }
    };
  });
</script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.0.0"></script>



  

  
    
  

  <script type="text/javascript">
    var duoshuoQuery = {short_name:"fenghexo"};
    (function() {
      var ds = document.createElement('script');
      ds.type = 'text/javascript';ds.async = true;
      ds.id = 'duoshuo-script';
      //ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
      ds.src = '/js/src/embed.js';
      ds.charset = 'UTF-8';
      (document.getElementsByTagName('head')[0]
      || document.getElementsByTagName('body')[0]).appendChild(ds);
    })();
  </script>

  
    
  






  
  

  

<script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"1","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"16"},"slide":{"type":"slide","bdImg":"3","bdPos":"left","bdTop":"250"}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script>


  

  <script type="text/javascript">

  $(document).ready(function(){
    var isMobile = navigator.userAgent.match(/iphone|android|phone|mobile|wap|netfront|x11|java|opera mobi|opera mini|ucweb|windows ce|symbian|symbianos|series|webos|sony|blackberry|dopod|nokia|samsung|palmsource|xda|pieplus|meizu|midp|cldc|motorola|foma|docomo|up.browser|up.link|blazer|helio|hosin|huawei|novarra|coolpad|webos|techfaith|palmsource|alcatel|amoi|ktouch|nexian|ericsson|philips|sagem|wellcom|bunjalloo|maui|smartphone|iemobile|spice|bird|zte-|longcos|pantech|gionee|portalmmm|jig browser|hiptop|benq|haier|^lct|320x320|240x320|176x220/i);
    isMobile = (isMobile != null);
  if (!isMobile) {
    $(function() {
        var $sidebar   = $("#sidebar"),
            $window    = $(window),
            $header    = $("#header-inner"),
            offset     = $sidebar.offset(),
            topPadding = 15;

        $window.scroll(function() {
            if ($window.scrollTop() > offset.top) {
              //console.log($window.scrollTop());
              //console.log(offset.top);
                $sidebar.stop().animate({
                    //marginTop: $window.scrollTop() - offset.top + topPadding
                    marginTop: $window.scrollTop()  + topPadding
                });
            } else {
                $sidebar.stop().animate({
                    marginTop: offset.top
                });
            }
        });

    });
    }
  });
  </script>

</body>
</html>
